﻿#include <QCoreApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>

#include "g_ver.h"
#include "encoder.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    a.setApplicationName(SP_NAME);
    a.setApplicationVersion(SP_VERSION);

    QCommandLineParser parser;
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("input","input file");
    parser.addPositionalArgument("output","output file");
    QCommandLineOption decodeOption(QStringList() << "d" << "decode","decode option");
    parser.addOption(decodeOption);
    parser.process(a);

    const QStringList args=parser.positionalArguments();
    if(args.isEmpty())
    {
        qDebug() << "missing parameter";
        return 0;
    }
    else if(args.size() == 2)
    {
        QString infile=args.at(0);
        QString outfile=args.at(1);
        if(parser.isSet(decodeOption))
            decode(infile,outfile);
        else
            encode(infile,outfile);
    }

    return 0;
}
